package com.lanqiao.controller;

import cn.hutool.json.JSONUtil;
import com.lanqiao.dao.UserDao;
import com.lanqiao.dao.impl.UserDaoImpl;
import com.lanqiao.entity.UserInfo;
import com.lanqiao.service.UserSeivice;
import com.lanqiao.service.impl.UserSeiviceImpl;
import jdk.nashorn.internal.objects.NativeMath;
import org.lanqiao.mvc.entity.ModelAndView;
import org.lanqiao.mvc.entity.YockMvcAnnotation;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@YockMvcAnnotation.Controller("/userby")
public class UserberController {
UserSeivice userSeivice = new UserSeiviceImpl();




    @YockMvcAnnotation.RequestMapping("/userpage.action")
    @YockMvcAnnotation.ResponseDispatch("/WEB-INF/view/accountmanager.jsp")
    public ModelAndView userpage(
            HttpServletRequest request,
            HttpServletResponse response
    ) throws Exception{
        ModelAndView model = new ModelAndView();


        String stu_name = request.getParameter("stu_name");
        String date = request.getParameter("date");
        String stu_sex = request.getParameter("stu_sex");


        int a= -1;

        System.out.println(stu_name);
        System.out.println(date);
        System.out.println(stu_sex);
        if(stu_sex!=null){
            a =Integer.parseInt(stu_sex);
        }



        List<UserInfo> userdcf = userSeivice.selectuser(stu_name,date,a);

        System.out.println(userdcf);
        model.addObject("userdcf",userdcf);


        return model;
    }

    @YockMvcAnnotation.RequestMapping("/userpage2.action")
    @YockMvcAnnotation.ResponseDispatch("/WEB-INF/view/adduser.jsp")
    public ModelAndView userpage2(
            HttpServletRequest request,
            HttpServletResponse response
    ) throws Exception{
        ModelAndView model = new ModelAndView();




        return model;
    }




}
